home *** CD-ROM | disk | FTP | other *** search
- package com.extensibility.xml;
-
- import com.extensibility.xml.dt.DataType;
- import com.extensibility.xml.dt.DataTypeIntf;
- import java.io.IOException;
- import java.util.Enumeration;
- import java.util.Vector;
-
- public class MetaSchemaFlavor extends XDRFlavor implements ExtraMetaDataUIIntf {
- String name;
- SchemaIntf metaschema;
- Vector elemDefs = new Vector();
- Vector elemRefs = new Vector();
- Vector attrDefs = new Vector();
- Vector schemaProps = new Vector();
-
- public MetaSchemaFlavor(SchemaIntf var1, String var2) {
- super(var1);
- this.name = var2;
- }
-
- public void setMetaschema(URI var1) throws Exception {
- String var2 = SchemaUtilities.getFlavor(var1, false);
- this.metaschema = new Schema(var1, var2);
- this.metaschema.parse(var1, 0, (Object)null);
- this.createMetaInfo();
- }
-
- public String getFlavorName() {
- return this.name;
- }
-
- public String getExtensionsName() {
- String var1 = (String)this.metaschema.getMetaPropHash().getMetaProp("xams:name");
- return var1 != null ? var1 : this.name;
- }
-
- public static boolean isValid(String var0, URI var1) {
- String var2 = var1.getFullName();
- if (var2.indexOf(String.valueOf(".").concat(String.valueOf(var0))) == var2.length() - var0.length() - 1) {
- return true;
- } else {
- return SchemaUtilities.getFlavor(var1, false) != null;
- }
- }
-
- public void parse(URI var1, URI var2, int var3, Object var4) throws IOException {
- super.parse(var1, var2, var3, var4);
- String[] var5 = this.getNamespaces();
- if (var5 != null) {
- for(int var6 = 0; var6 < var5.length - 1; var6 += 2) {
- NamespaceDeclaration var7 = super.schema.getNamedNamespace(var5[var6]);
- if (var7 != null) {
- super.schema.removeDeclaration(var7);
- }
- }
- }
-
- }
-
- protected void buildInfos(String var1, Vector var2) {
- ElementDeclaration var3 = this.metaschema.getNamedElement(var1);
- if (var3 != null) {
- ContentModelTermEnum var4 = var3.getContentModel().getLeafTerms();
-
- while(var4.hasMoreElements()) {
- ContentModelTerm var5 = var4.nextContentModelTerm();
- CMTReferent var6 = var5.getReferent();
- if (var6 instanceof ElementDeclaration) {
- ElementDeclaration var7 = (ElementDeclaration)var6;
- Class var8 = this.getClass(var7);
- double var9 = this.getWeight(var7);
- int var11 = this.getWidth(var7);
- String var12 = this.getColName(var7);
- String var13 = this.getIdFrom(var7);
- var2.addElement(new MetaPropUIInfo(var12, String.valueOf(String.valueOf(this.name).concat(String.valueOf(":"))).concat(String.valueOf(var5.getTerm())), var8, var9, var11, var13, var7.getDataType(), (String)null));
- }
- }
-
- Enumeration var16 = var3.getOwnedAttributes();
-
- while(var16.hasMoreElements()) {
- AttributeDeclaration var17 = (AttributeDeclaration)var16.nextElement();
- String var18 = ((BaseDeclaration)var17).getName();
- if (!var18.equals("which")) {
- Class var19 = this.getClass(var17);
- double var20 = this.getWeight(var17);
- int var21 = this.getWidth(var17);
- String var22 = this.getColName(var17);
- String var23 = this.getIdFrom(var17);
- DataType var14 = var17.getDataType();
- String var15 = var17.getDefault();
- var2.addElement(new MetaPropUIInfo(var22, String.valueOf(String.valueOf(this.name).concat(String.valueOf(":"))).concat(String.valueOf(var18)), var19, var20, var21, var23, var14, var15));
- }
- }
- }
-
- }
-
- protected Class getClass(BaseDeclaration var1) {
- return Class.forName("java.lang.String");
- }
-
- protected double getWeight(BaseDeclaration var1) {
- Object var2 = var1.getMetaProp("xams:colWeight");
- return var2 == null ? 0.1 : Double.valueOf(var2.toString());
- }
-
- protected int getWidth(BaseDeclaration var1) {
- Object var2 = var1.getMetaProp("xams:colWidth");
- return var2 == null ? 80 : Integer.valueOf(var2.toString());
- }
-
- protected String getColName(BaseDeclaration var1) {
- Object var2 = var1.getMetaProp("xams:colName");
- return var2 == null ? var1.getName() : var2.toString();
- }
-
- protected String getIdFrom(BaseDeclaration var1) {
- Object var2 = var1.getMetaProp("xams:idFrom");
- return var2 == null ? "" : var2.toString();
- }
-
- protected void createMetaInfo() {
- this.buildInfos("element", this.elemDefs);
- this.buildInfos("subelement", this.elemRefs);
- this.buildInfos("attribute", this.attrDefs);
- this.buildInfos("schema", this.schemaProps);
- }
-
- public int getExtraColumnCount(int var1) {
- return this.getCount(var1);
- }
-
- public String getColumnName(int var1, int var2) {
- return this.getInfo(var1, var2).colName;
- }
-
- public Class getColumnClass(int var1, int var2) {
- return this.getInfo(var1, var2).colClass;
- }
-
- public int getInitialColumnWidth(int var1, int var2) {
- return this.getInfo(var1, var2).colInitialWidth;
- }
-
- public double getColumnWeight(int var1, int var2) {
- return this.getInfo(var1, var2).colWeight;
- }
-
- public String getColumnIdFrom(int var1, int var2) {
- return this.getInfo(var1, var2).idFrom;
- }
-
- public String getColumnMetaProp(int var1, int var2) {
- return this.getInfo(var1, var2).metaprop;
- }
-
- public boolean isColumnMetaPropList(int var1, int var2) {
- return this.getInfo(var1, var2).isListOfSubElements;
- }
-
- public boolean isColumnMetaPropAttrs(int var1, int var2) {
- return this.getInfo(var1, var2).isSubElementWithAttrs;
- }
-
- public DataTypeIntf getDataType(int var1, int var2) {
- return this.getInfo(var1, var2).dataType;
- }
-
- public String getDefaultValue(int var1, int var2) {
- return this.getInfo(var1, var2).defaultValue;
- }
-
- public String[] getNamespaces() {
- String var1 = (String)this.metaschema.getMetaPropHash().getMetaProp("xams:namespace");
- if (var1 == null && this.metaschema.getNamespace() != null) {
- var1 = this.metaschema.getNamespace().toSource();
- }
-
- if (var1 == null) {
- var1 = "";
- }
-
- return new String[]{this.name, var1};
- }
-
- protected int getCount(int var1) {
- Vector var2 = this.getInfo(var1);
- return var2 == null ? 0 : var2.size();
- }
-
- protected Vector getInfo(int var1) {
- switch (var1) {
- case 1:
- return this.elemDefs;
- case 2:
- return this.elemRefs;
- case 3:
- case 4:
- return this.attrDefs;
- case 5:
- return this.schemaProps;
- default:
- return null;
- }
- }
-
- protected MetaPropUIInfo getInfo(int var1, int var2) {
- return (MetaPropUIInfo)this.getInfo(var1).elementAt(var2);
- }
- }
-